/*
Segment Tree Rewrite
*/
#include <cstdio>
#include <iostream>
#include <vector>
#define lld long long

using namespace std;

class SegmentTree {
private:
    struct TreeNode {
        int from, to;
        lld sum, lazy;
        TreeNode(int f, int t, lld s) {
            from = f;
            to = t;
            sum = s;
            lazy = 0;
        }
    };
    int Len;
    vector<lld> LeaveNode;
    vector<TreeNode> Tree;

    void __BUILDTREE(int i, int f, int t) {
        if (f == t) {
            Tree[i] = TreeNode(f, t, LeaveNode[f]);
            return;
        }
        int left = i * 2;
        int right = i * 2 + 1;
        int mid = (f + t) / 2;

        __BUILDTREE(left, f, mid);
        __BUILDTREE(right, mid + 1, t);

        int leftSum = Tree[left].sum;
        int rightSum = Tree[right].sum;
        Tree[i] = TreeNode(f, t, leftSum + rightSum);
        return;
    }

    void __UPDATE(int i) {
        auto rangeLen = [this](int j) -> lld { return (lld)((this->Tree[j].to) - (this->Tree[j].from) + 1); };
        int left = i * 2;
        int right = i * 2 + 1;
        lld lazy = Tree[i].lazy;

        Tree[left].sum += lazy * rangeLen(left);
        Tree[left].lazy += lazy;
        Tree[right].sum += lazy * rangeLen(right);
        Tree[right].lazy += lazy;
        Tree[i].lazy = 0;
        return;
    }

    lld __VISIT(int i, int f, int t) {
        if (f > t)
            return 0;
        if (Tree[i].from == f && Tree[i].to == t) {
            return Tree[i].sum;
        } else {
            __UPDATE(i);
            int left = i * 2;
            int right = i * 2 + 1;
            int mid = (Tree[i].from + Tree[i].to) / 2;

            if (Tree[i].from <= f && t <= mid)
                return __VISIT(left, f, t);
            else if (mid + 1 <= f && t <= Tree[i].to)
                return __VISIT(right, f, t);
            else
                return __VISIT(left, f, mid) + __VISIT(right, mid + 1, t);
        }
    }

    void __MODIFY(int i, int f, int t, lld val) {
        auto rangeLen = [this](int j) -> lld { return (lld)((this->Tree[j].to) - (this->Tree[j].from) + 1); };
        if (f > t)
            return;
        if (Tree[i].from == f && Tree[i].to == t) {
            Tree[i].sum += rangeLen(i) * val;
            Tree[i].lazy += val;
            return;
        } else {
            __UPDATE(i);
            int left = i * 2;
            int right = i * 2 + 1;
            int mid = (Tree[i].from + Tree[i].to) / 2;

            if (Tree[i].from <= f && t <= mid)
                __MODIFY(left, f, t, val);
            else if (mid + 1 <= f && t <= Tree[i].to)
                __MODIFY(right, f, t, val);
            else {
                __MODIFY(left, f, mid, val);
                __MODIFY(right, mid + 1, t, val);
            }
            Tree[i].sum = Tree[left].sum + Tree[right].sum;
            return;
        }
    }

public:
    SegmentTree(int f, int t, vector<lld>& nums) : Len(t - f + 1), LeaveNode(t - f + 1, 0), Tree(4 * (t - f + 1) + 1, TreeNode(0, 0, 0)) {
        for (int i = 0; i < Len; i++) LeaveNode[i] = nums[i];
    }

    void BuildTree(int f, int t) {
        __BUILDTREE(1, f, t);
    }

    void Modify(int f, int t, int val) {
        __MODIFY(1, f, t, val);
    }

    lld Visit(int f, int t) {
        return __VISIT(1, f, t);
    }

    void PrintTree() {
        cout << "\n--->--------------------------------<---\n";
        for (int i = 1; i <= 4 * Len; i++) {
            printf("Node %3d | %3d~%3d | sum: %3lld\n", i, Tree[i].from, Tree[i].to, Tree[i].sum);
        }
        cout << "--->--------------------------------<---\n";
    }
};

int main() {
    // cout<<"hello";
    int n, m;
    cin >> n >> m;
    vector<lld> nums(n);
    for (int i = 0; i < n; i++) cin >> nums[i];
    SegmentTree s(0, n - 1, nums);
    s.BuildTree(0, n - 1);

    for (int i = 0; i < m; i++) {
        int c, f, t;
        lld v;
        cin >> c >> f >> t;
        if (c - 1) {
            cout << s.Visit(f - 1, t - 1) << endl;
        } else {
            cin >> v;
            s.Modify(f - 1, t - 1, v);
        }
    }
}